#include <iostream>
using namespace std;
const int N = 15;
bool st1[N * 2] , st2[N * 2] , col[N];
int n , ret;
void dfs(int x)
{
  if(x > n)
  {
    ret++;
    return ;
  }
  for(int y = 1; y <= n; y++)
  {
    if(col[y] || st1[y  +  x] || st2[y - x + n])continue;
    col[y] = st1[y + x] = st2[y - x + n] = true;
    dfs(x + 1);
    col[y] = st1[y + x] = st2[y - x + n] = false;
  }
}
int main()
{
  cin >> n;
  dfs(1);
  cout << ret <<  endl;
  return 0;
}
